import { createSlice } from '@reduxjs/toolkit'

// interface type {
//     _id: string,
//     title: string,
//     icon: string,
//     type: string,
//     show: boolean,
//     path: string,
//     parentId: string,
//     order: number,
//     creator: string,
//     component: string
// }


export const adminSlice = createSlice({
    // 当前切片名称
    name: 'admin',
    // 保存公共数据
    initialState: {
        adminInfo: {
            // _id: '',
            // name: '',
            // password: '',
            // roleId: [],
        }
    },
    // 修改state数据的公共方法
    reducers: {
        setAdminInfo: (state, action) => {
            // action.payload 用来接收外部传递的数据
            state.adminInfo = action.payload;
        },

    },
})

// 将reducers中的方法暴露出去
export const { setAdminInfo } = adminSlice.actions
export default adminSlice.reducer